1 // Autor: Alejandro Sotelo
2 // Por compatibilidad en la codificacion, se eliminaron las tildes de este archivo
5 public class gattaca_Sotelo2
{
6 public static void main(String
[] args
) throws Exception
{
7 BufferedReader br
=new BufferedReader(new FileReader("gattaca.in"));
8 for (int T
=Integer
.parseInt(br
.readLine()),c
=0; c
<T
; c
++) {
9 String s
=br
.readLine();
10 int n
=s
.length(),veces
=0;
11 String res
=null,arr
[]=new String
[n
+1];
12 for (int k
=0; k
<=n
; k
++) arr
[k
]=s
.substring(k
);
14 for (int k
=1; k
<=n
; k
++) {
16 while (i
<arr
[k
-1].length()&&i
<arr
[k
].length()&&arr
[k
-1].charAt(i
)==arr
[k
].charAt(i
)) i
++;
18 if (res
==null||i
>res
.length()||(i
==res
.length()&&arr
[k
].substring(0,i
).compareTo(res
)<0)) {
20 res
=arr
[k
].substring(0,i
);
22 else if (i
==res
.length()&&arr
[k
].substring(0,i
).equals(res
)) veces
++;
24 System
.out
.println(res
==null?
"No repetitions found!":(res
+" "+veces
));